import unittest
import requests
import pandas as pd
import ddt

url = "http://127.0.0.1:5000/"

file = pd.read_csv('../data/delete_test.csv')
df = pd.DataFrame(file)
data = df.to_dict(orient='records')


# 在测试类上加上装饰器:@ddt.ddt
@ddt.ddt
class DeleteTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        print("-----开始执行用例Delete-----")

    # 在需要使用数据的方法上加上装饰器:@ddt:data
    @ddt.data(*data)
    def testDeleteSuccess(self, data):
        code = 200
        ret = {'code': 200, 'message': '删除成功'}
        # 结果
        result = requests.post(url=url + "delete", data=data).json()
        print(result)
        self.assertDictEqual(ret, result)
        self.assertEqual(code, result.get("code"))

    @classmethod
    def tearDownClass(cls) -> None:
        print("-----用例Delete执行结束-----")
